Files
libreoffice/sd/source/ui/func/fuconuno.cxx

157 lines
4.6 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <fuconuno.hxx>
#include <rtl/ustring.hxx>
#include <svl/aeitem.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
#include <svl/intitem.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/fmglob.hxx>
#include <svx/dialogs.hrc>
#include <app.hrc>
#include <strings.hrc>
#include <ViewShell.hxx>
#include <View.hxx>
#include <Window.hxx>
#include <ViewShellBase.hxx>
#include <ToolBarManager.hxx>
#include <drawdoc.hxx>
#include <unokywds.hxx>
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
2000-09-18 16:07:07 +00:00
namespace sd {
2000-09-18 16:07:07 +00:00
FuConstructUnoControl::FuConstructUnoControl (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq)
2000-09-18 16:07:07 +00:00
: FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
, nInventor(SdrInventor::Unknown)
, nIdentifier(0)
2000-09-18 16:07:07 +00:00
{
}
rtl::Reference<FuPoor> FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
{
FuConstructUnoControl* pFunc;
rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
pFunc->SetPermanent(bPermanent);
return xFunc;
}
void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
{
FuConstruct::DoExecute( rReq );
const SfxUInt32Item* pInventorItem = rReq.GetArg<SfxUInt32Item>(SID_FM_CONTROL_INVENTOR);
const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
2000-09-18 16:07:07 +00:00
if( pInventorItem )
nInventor = static_cast<SdrInventor>(pInventorItem->GetValue());
2000-09-18 16:07:07 +00:00
if( pIdentifierItem )
nIdentifier = pIdentifierItem->GetValue();
mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
ToolBarManager::ToolBarGroup::Function,
ToolBarManager::msDrawingObjectToolBar);
2000-09-18 16:07:07 +00:00
}
bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
2000-09-18 16:07:07 +00:00
if ( rMEvt.IsLeft() && !mpView->IsAction() )
2000-09-18 16:07:07 +00:00
{
Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
mpWindow->CaptureMouse();
sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
bReturn = true;
2000-09-18 16:07:07 +00:00
}
return bReturn;
}
bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
bool bReturn = false;
2000-09-18 16:07:07 +00:00
if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
2000-09-18 16:07:07 +00:00
{
mpView->EndCreateObj(SdrCreateCmd::ForceEnd);
bReturn = true;
2000-09-18 16:07:07 +00:00
}
bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
if (!bPermanent)
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
2000-09-18 16:07:07 +00:00
return bReturn;
2000-09-18 16:07:07 +00:00
}
void FuConstructUnoControl::Activate()
2000-09-18 16:07:07 +00:00
{
mpView->SetCurrentObj( nIdentifier, nInventor );
2000-09-18 16:07:07 +00:00
aNewPointer = Pointer(PointerStyle::DrawRect);
aOldPointer = mpWindow->GetPointer();
mpWindow->SetPointer( aNewPointer );
2000-09-18 16:07:07 +00:00
aOldLayer = mpView->GetActiveLayer();
mpView->SetActiveLayer(sUNO_LayerName_controls);
2000-09-18 16:07:07 +00:00
FuConstruct::Activate();
}
void FuConstructUnoControl::Deactivate()
2000-09-18 16:07:07 +00:00
{
FuConstruct::Deactivate();
mpView->SetActiveLayer( aOldLayer );
mpWindow->SetPointer( aOldPointer );
2000-09-18 16:07:07 +00:00
}
SdrObjectUniquePtr FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
{
// case SID_FM_CREATE_CONTROL:
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
SOSAW080: Added first bunch of basic changes to helpers SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078 Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c Reviewed-on: https://gerrit.libreoffice.org/52526 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-03-01 15:54:32 +01:00
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier()));
if(pObj)
{
pObj->SetLogicRect(rRectangle);
}
2000-09-18 16:07:07 +00:00
return pObj;
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */