diff options
34 files changed, 285 insertions, 310 deletions
diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx index 0e5b93a5e861..94b3b029062f 100644 --- a/include/svtools/tabbar.hxx +++ b/include/svtools/tabbar.hxx @@ -376,6 +376,8 @@ private: protected: virtual void AddTabClick(); + OUString GetAuxiliaryText(sal_uInt16 nPageId) const; // needed in derived class LayerTabBar + void SetAuxiliaryText(sal_uInt16 nPageId, const OUString& rText ); public: static const sal_uInt16 APPEND; @@ -405,7 +407,7 @@ public: virtual void EndRenaming(); virtual void Mirror(); - void InsertPage( sal_uInt16 nPageId, const OUString& rText, + virtual void InsertPage( sal_uInt16 nPageId, const OUString& rText, TabBarPageBits nBits = TabBarPageBits::NONE, sal_uInt16 nPos = TabBar::APPEND ); void RemovePage( sal_uInt16 nPageId ); @@ -474,7 +476,7 @@ public: void SwitchPage( const Point& rPos ); void EndSwitchPage(); - void SetPageText( sal_uInt16 nPageId, const OUString& rText ); + virtual void SetPageText( sal_uInt16 nPageId, const OUString& rText ); OUString GetPageText( sal_uInt16 nPageId ) const; OUString GetHelpText( sal_uInt16 nPageId ) const; OString GetHelpId( sal_uInt16 nPageId ) const; diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 3bb367c4bbd0..fae113555f12 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -100,6 +100,7 @@ #include <undopage.hxx> #include <tools/tenccvt.hxx> #include <vcl/settings.hxx> +#include <unokywds.hxx> using namespace ::sd; using namespace ::com::sun::star; @@ -313,28 +314,34 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) * * We create the following default layers on all pages and master pages: * - * STR_LAYOUT : default layer for drawing objects + * sUNO_LayerName_layout; "layout": default layer for drawing objects of normal pages + * localized by SdResId(STR_LAYER_LAYOUT) * - * STR_BCKGRND : background of the master page - * (currently unused within normal pages) + * sUNO_LayerName_background; "background": background of the master page + * localized by SdResId(STR_LAYER_BCKGRND) + * (currently unused within normal pages and not visible to users) * - * STR_BCKGRNDOBJ: objects on the background of master pages - * (currently unused within normal pages) + * sUNO_LayerName_background_objects; "backgroundobjects": objects on the background of master pages + * localized by SdResId(STR_LAYER_BCKGRNDOBJ) + * (currently unused within normal pages) * - * STR_CONTROLS : default layer for controls + * sUNO_LayerName_controls; "controls": default layer for controls + * localized by SdResId(STR_LAYER_CONTROLS) + * (currently special handling in regard to z-order) + * + * sUNO_LayerName_measurelines; "measurelines" : default layer for measure lines + * localized by SdResId(STR_LAYER_MEASURELINES) */ { - OUString aControlLayerName( SdResId(STR_LAYER_CONTROLS) ); - SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); - rLayerAdmin.NewLayer( SdResId(STR_LAYER_LAYOUT) ); - rLayerAdmin.NewLayer( SdResId(STR_LAYER_BCKGRND) ); - rLayerAdmin.NewLayer( SdResId(STR_LAYER_BCKGRNDOBJ) ); - rLayerAdmin.NewLayer( aControlLayerName ); - rLayerAdmin.NewLayer( SdResId(STR_LAYER_MEASURELINES) ); + rLayerAdmin.NewLayer( sUNO_LayerName_layout ); + rLayerAdmin.NewLayer( sUNO_LayerName_background ); + rLayerAdmin.NewLayer( sUNO_LayerName_background_objects ); + rLayerAdmin.NewLayer( sUNO_LayerName_controls); + rLayerAdmin.NewLayer( sUNO_LayerName_measurelines ); - rLayerAdmin.SetControlLayerName(aControlLayerName); + rLayerAdmin.SetControlLayerName(sUNO_LayerName_controls); } } @@ -753,9 +760,6 @@ void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode) pPage->SetName( aName ); } - // Create names of the default layers in the user's language - RestoreLayerNames(); - // Create names of the styles in the user's language static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames(); diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 9a17fd2a36d0..11f30034c3e4 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -68,6 +68,7 @@ #include "PageListWatcher.hxx" #include <vcl/virdev.hxx> #include <customshowlist.hxx> +#include <unokywds.hxx> using namespace ::sd; @@ -1342,8 +1343,8 @@ sal_uInt16 SdDrawDocument::DuplicatePage (sal_uInt16 nPageNum) // Get background flags SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers(); return DuplicatePage ( @@ -1486,8 +1487,8 @@ void SdDrawDocument::SetupNewPage ( if (pPreviousPage != nullptr) { SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers = pPreviousPage->TRG_GetMasterPageVisibleLayers(); aVisibleLayers.Set(aBckgrnd, bIsPageBack); aVisibleLayers.Set(aBckgrndObj, bIsPageObj); diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index d11495bd29bc..d4a56c215b29 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -1065,45 +1065,6 @@ void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo const * pInfo, Sdr SfxViewFrame::Current()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON ); } -// Replace the unambiguous names of the default layers by their names in the -// native language -void SdDrawDocument::RestoreLayerNames() -{ - SdrLayerAdmin& rLayerAdmin = GetLayerAdmin(); - sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount(); - - for (sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++) - { - SdrLayer* pLayer = rLayerAdmin.GetLayer(nLayer); - - if (pLayer) - { - OUString aLayerName(pLayer->GetName()); - - if (aLayerName == "LAYER_LAYOUT") - { - pLayer->SetName(SdResId(STR_LAYER_LAYOUT)); - } - else if (aLayerName == "LAYER_BCKGRND") - { - pLayer->SetName(SdResId(STR_LAYER_BCKGRND)); - } - else if (aLayerName == "LAYER_BACKGRNDOBJ") - { - pLayer->SetName(SdResId(STR_LAYER_BCKGRNDOBJ)); - } - else if (aLayerName == "LAYER_CONTROLS") - { - pLayer->SetName(SdResId(STR_LAYER_CONTROLS)); - } - else if (aLayerName == "LAYER_MEASURELINES") - { - pLayer->SetName(SdResId(STR_LAYER_MEASURELINES)); - } - } - } -} - // Return formatted page number (1, I, i, a, etc.) OUString SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const { diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 3901a13c008d..ce76e92a6d78 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -82,6 +82,7 @@ #include <svx/sdr/contact/viewcontact.hxx> #include <svx/sdr/contact/objectcontact.hxx> #include <svx/unoapi.hxx> +#include <unokywds.hxx> #include <set> @@ -529,8 +530,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrPage().GetLayerAdmin()); // background objects of the master page - pSdrObj->SetLayer( rLayerAdmin. - GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)) ); + pSdrObj->SetLayer( rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects) ); } // Subscribe object at the style sheet diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index c885ed988ac5..16ed1e845c9a 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -76,6 +76,7 @@ #include <DrawDocShell.hxx> #include <FrameView.hxx> #include <optsitem.hxx> +#include <unokywds.hxx> #include <unotools/fltrcfg.hxx> #include <sfx2/progress.hxx> @@ -251,8 +252,8 @@ bool ImplSdPPTImport::Import() const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord ); SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin(); - mnBackgroundLayerID = rAdmin.GetLayerID( SdResId( STR_LAYER_BCKGRND ) ); - mnBackgroundObjectsLayerID = rAdmin.GetLayerID( SdResId( STR_LAYER_BCKGRNDOBJ ) ); + mnBackgroundLayerID = rAdmin.GetLayerID( sUNO_LayerName_background ); + mnBackgroundObjectsLayerID = rAdmin.GetLayerID( sUNO_LayerName_background_objects ); ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh(); if ( pDocShell ) diff --git a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx index bf9fd9b89f7a..ccb908089a0e 100644 --- a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx +++ b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx @@ -707,11 +707,12 @@ uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() { sName = "page-name:"; sValue = sName; + OUString sLayerName(pDrViewSh->GetLayerTabControl()->GetLayerName(pDrViewSh->GetLayerTabControl()->GetCurPageId()) ); sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId()); if( pDoc ) { SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); - SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sDisplay); + SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sLayerName); if( aSdrLayer ) { OUString layerAltText = aSdrLayer->GetTitle(); diff --git a/sd/source/ui/dlg/LayerTabBar.cxx b/sd/source/ui/dlg/LayerTabBar.cxx index 56de16045ab8..fdd45ddcee68 100644 --- a/sd/source/ui/dlg/LayerTabBar.cxx +++ b/sd/source/ui/dlg/LayerTabBar.cxx @@ -35,6 +35,7 @@ #include <View.hxx> #include <drawdoc.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <DrawDocShell.hxx> #include <drawview.hxx> #include <undolayer.hxx> @@ -66,6 +67,71 @@ void LayerTabBar::dispose() TabBar::dispose(); } +OUString LayerTabBar::convertToLocalizedName(const OUString& rName) +{ + if ( rName == sUNO_LayerName_background ) + return SdResId( STR_LAYER_BCKGRND ); + + if ( rName == sUNO_LayerName_background_objects ) + return SdResId( STR_LAYER_BCKGRNDOBJ ); + + if ( rName == sUNO_LayerName_layout ) + return SdResId( STR_LAYER_LAYOUT ); + + if ( rName == sUNO_LayerName_controls ) + return SdResId( STR_LAYER_CONTROLS ); + + if ( rName == sUNO_LayerName_measurelines ) + return SdResId( STR_LAYER_MEASURELINES ); + + return rName; +} + +// Use a method name, that is specific to LayerTabBar to make code better readable +OUString LayerTabBar::GetLayerName(sal_uInt16 nPageId) const +{ + return GetAuxiliaryText(nPageId); +} + +void LayerTabBar::SetLayerName( sal_uInt16 nPageId, const OUString& rText ) +{ + SetAuxiliaryText(nPageId, rText); +} + +// Here "Page" is a tab in the LayerTabBar. +void LayerTabBar::InsertPage( sal_uInt16 nPageId, const OUString& rText, + TabBarPageBits nBits, sal_uInt16 nPos) +{ + OUString sLocalizedName(convertToLocalizedName(rText)); + TabBar::InsertPage(nPageId, sLocalizedName, nBits, nPos ); + SetLayerName(nPageId, rText); +} + +void LayerTabBar::SetPageText( sal_uInt16 nPageId, const OUString& rText ) +{ + OUString sLocalizedName(convertToLocalizedName(rText)); + SetLayerName(nPageId, rText); + TabBar::SetPageText(nPageId, sLocalizedName); +} + +bool LayerTabBar::IsLocalizedNameOfStandardLayer(const OUString& rName) +{ + return ( rName == SdResId(STR_LAYER_LAYOUT) + || rName == SdResId(STR_LAYER_CONTROLS) + || rName == SdResId(STR_LAYER_MEASURELINES) + || rName == SdResId(STR_LAYER_BCKGRND) + || rName == SdResId(STR_LAYER_BCKGRNDOBJ) ); +} + +bool LayerTabBar::IsRealNameOfStandardLayer(const OUString& rName) +{ + return ( rName == sUNO_LayerName_layout + || rName == sUNO_LayerName_controls + || rName == sUNO_LayerName_measurelines + || rName == sUNO_LayerName_background + || rName == sUNO_LayerName_background_objects ); +} + void LayerTabBar::Select() { SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); @@ -76,23 +142,32 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt) { bool bSetPageID=false; - if (rMEvt.IsLeft() && !rMEvt.IsMod2()) + if (rMEvt.IsLeft()) { Point aPosPixel = rMEvt.GetPosPixel(); - sal_uInt16 aLayerId = GetPageId( PixelToLogic(aPosPixel) ); - - if (aLayerId == 0) + sal_uInt16 aTabId = GetPageId( PixelToLogic(aPosPixel) ); + if (aTabId == 0) { SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); pDispatcher->Execute(SID_INSERTLAYER, SfxCallMode::SYNCHRON); bSetPageID=true; } + else if (rMEvt.IsMod2()) + { + // direct editing of tab text + // make sure the clicked tab is the current tab otherwise Edit() acts on the wrong tab + if ( aTabId != GetCurPageId()) + { + MouseEvent aSyntheticEvent (rMEvt.GetPosPixel(), 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0); + TabBar::MouseButtonDown(aSyntheticEvent); + } + } else if (rMEvt.IsMod1() || rMEvt.IsShift()) { // keyboard Shortcuts to change layer attributes - OUString aName(GetPageText(aLayerId)); + OUString aName(GetLayerName(aTabId)); SdrPageView* pPV = pDrViewSh->GetView()->GetSdrPageView(); // Save old state @@ -195,8 +270,8 @@ sal_Int8 LayerTabBar::AcceptDrop( const AcceptDropEvent& rEvt ) if( !pDrViewSh->GetDocSh()->IsReadOnly() ) { Point aPos( PixelToLogic( rEvt.maPosPixel ) ); - SdrLayerID nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID( - GetPageText( GetPageId( aPos ) ) ); + OUString sLayerName( GetLayerName(GetPageId(aPos)) ); + SdrLayerID nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(sLayerName); nRet = pDrViewSh->AcceptDrop( rEvt, *this, nullptr, SDRPAGE_NOTFOUND, nLayerId ); @@ -211,8 +286,10 @@ sal_Int8 LayerTabBar::AcceptDrop( const AcceptDropEvent& rEvt ) */ sal_Int8 LayerTabBar::ExecuteDrop( const ExecuteDropEvent& rEvt ) { - SdrLayerID nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID( - GetPageText( GetPageId( PixelToLogic( rEvt.maPosPixel ) ) ) ); + Point aPos( PixelToLogic(rEvt.maPosPixel) ); + OUString sLayerName( GetLayerName(GetPageId(aPos)) ); + SdrLayerID nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(sLayerName); + sal_Int8 nRet = pDrViewSh->ExecuteDrop( rEvt, *this, nullptr, SDRPAGE_NOTFOUND, nLayerId ); EndSwitchPage(); @@ -233,18 +310,11 @@ void LayerTabBar::Command(const CommandEvent& rCEvt) bool LayerTabBar::StartRenaming() { bool bOK = true; - OUString aLayerName = GetPageText( GetEditPageId() ); - OUString aLayoutLayer = SdResId(STR_LAYER_LAYOUT); - OUString aControlsLayer = SdResId(STR_LAYER_CONTROLS); - OUString aMeasureLinesLayer = SdResId(STR_LAYER_MEASURELINES); - OUString aBackgroundLayer = SdResId(STR_LAYER_BCKGRND); - OUString aBackgroundObjLayer = SdResId(STR_LAYER_BCKGRNDOBJ); - - if ( aLayerName == aLayoutLayer || aLayerName == aControlsLayer || - aLayerName == aMeasureLinesLayer || - aLayerName == aBackgroundLayer || aLayerName == aBackgroundObjLayer ) + OUString aLayerName = GetLayerName( GetEditPageId() ); + + if ( IsRealNameOfStandardLayer(aLayerName)) { - // It is not allowed to change this names + // It is not allowed to change these names bOK = false; } else @@ -274,7 +344,7 @@ TabBarAllowRenamingReturnCode LayerTabBar::AllowRenaming() if (aNewName.isEmpty() || (rLayerAdmin.GetLayer( aNewName ) && aLayerName != aNewName) ) { - // Name already exists + // Name already exists. std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pDrViewSh->GetViewFrame()->GetWindow().GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_WARN_NAME_DUPLICATE))); @@ -284,17 +354,9 @@ TabBarAllowRenamingReturnCode LayerTabBar::AllowRenaming() if (bOK) { - OUString aLayoutLayer = SdResId(STR_LAYER_LAYOUT); - OUString aControlsLayer = SdResId(STR_LAYER_CONTROLS); - OUString aMeasureLinesLayer = SdResId(STR_LAYER_MEASURELINES); - OUString aBackgroundLayer = SdResId(STR_LAYER_BCKGRND); - OUString aBackgroundObjLayer = SdResId(STR_LAYER_BCKGRNDOBJ); - - if ( aNewName == aLayoutLayer || aNewName == aControlsLayer || - aNewName == aMeasureLinesLayer || - aNewName == aBackgroundLayer || aNewName == aBackgroundObjLayer ) + if ( IsLocalizedNameOfStandardLayer(aNewName) || IsRealNameOfStandardLayer(aNewName) ) { - // It is not allowed to use his names + // Standard layer names may not be changed. bOK = false; } } diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index bc7c814d562a..4b33fb965830 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -59,6 +59,7 @@ #include <Window.hxx> #include <stlpool.hxx> #include <drawdoc.hxx> +#include <unokywds.hxx> #include <strings.hrc> @@ -233,8 +234,7 @@ bool FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt) if(SID_DRAW_MEASURELINE == nSlotId) { SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin(); - OUString aStr(SdResId(STR_LAYER_MEASURELINES)); - pObj->SetLayer(rAdmin.GetLayerID(aStr)); + pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines)); } // init text position when vertical caption object is created @@ -493,8 +493,7 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) } SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin(); - OUString aStr(SdResId(STR_LAYER_MEASURELINES)); - pObj->SetLayer(rAdmin.GetLayerID(aStr)); + pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines)); } } diff --git a/sd/source/ui/func/fuconuno.cxx b/sd/source/ui/func/fuconuno.cxx index ca9f9c8eed80..c940dca65bca 100644 --- a/sd/source/ui/func/fuconuno.cxx +++ b/sd/source/ui/func/fuconuno.cxx @@ -37,7 +37,7 @@ #include <ViewShellBase.hxx> #include <ToolBarManager.hxx> #include <drawdoc.hxx> -#include <sdresid.hxx> +#include <unokywds.hxx> namespace sd { @@ -122,7 +122,7 @@ void FuConstructUnoControl::Activate() mpWindow->SetPointer( aNewPointer ); aOldLayer = mpView->GetActiveLayer(); - mpView->SetActiveLayer( SdResId(STR_LAYER_CONTROLS) ); + mpView->SetActiveLayer(sUNO_LayerName_controls); FuConstruct::Activate(); } diff --git a/sd/source/ui/inc/LayerTabBar.hxx b/sd/source/ui/inc/LayerTabBar.hxx index 496f3e9b7865..ffc9071999f1 100644 --- a/sd/source/ui/inc/LayerTabBar.hxx +++ b/sd/source/ui/inc/LayerTabBar.hxx @@ -53,6 +53,27 @@ public: */ void SendDeactivatePageEvent(); + // Expects not-localized, real layer name in rText. Generates a localized layer name + // that will be displayed on the tab of the LayerTabBar and writes the real name + // to maAuxiliaryText. In case you want no entry in maAuxiliaryText, use method from TabBar. + virtual void InsertPage( sal_uInt16 nPageId, const OUString& rText, + TabBarPageBits nBits = TabBarPageBits::NONE, + sal_uInt16 nPos = TabBar::APPEND ) override; + virtual void SetPageText( sal_uInt16 nPageId, const OUString& rText ) override; + + // Returns the real layer name if exists and empty OUString otherwise. + OUString GetLayerName(sal_uInt16 nPageId) const; + + // Used e.g. in DeleteActualLayer() to test whether deleting is allowed. + static bool IsRealNameOfStandardLayer(const OUString& rName); + + // Used e.g. in validity test of user entered names + static bool IsLocalizedNameOfStandardLayer(const OUString& rName); + + // In case rName is one of the sUNO_LayerName_*, it generates a localized name, + // otherwise it returns value of rName. + static OUString convertToLocalizedName(const OUString& rName); + private: DrawViewShell* pDrViewSh; @@ -72,6 +93,9 @@ private: // DropTargetHelper virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + + // Expects not-localized, real layer name in rText and writes it to maAuxiliaryText. + void SetLayerName( sal_uInt16 nPageId, const OUString& rText ); }; } // end of namespace sd diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index c2e597551f86..0f623c705a3f 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -29,6 +29,7 @@ #include <sdpage.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <bitmaps.hlst> #include <tools/SlotStateListener.hxx> #include <DrawController.hxx> @@ -454,10 +455,8 @@ SfxRequest LayoutMenu::CreateRequest ( do { SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin()); - SdrLayerID aBackground (rLayerAdmin.GetLayerID( - SdResId(STR_LAYER_BCKGRND))); - SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID( - SdResId(STR_LAYER_BCKGRNDOBJ))); + SdrLayerID aBackground (rLayerAdmin.GetLayerID(sUNO_LayerName_background)); + SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects)); ViewShell* pViewShell = mrBase.GetMainViewShell().get(); if (pViewShell == nullptr) break; diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index b95af6f2b617..11b222d0a0d1 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -51,6 +51,7 @@ #include <app.hrc> #include <strings.hrc> #include <sdresid.hxx> +#include <unokywds.hxx> #include <drawdoc.hxx> #include <DrawDocShell.hxx> #include <ViewShellBase.hxx> @@ -940,8 +941,8 @@ bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const OUStri // Undo SdPage* pUndoPage = pPageToRename; SdrLayerAdmin & rLayerAdmin = pDocument->GetLayerAdmin(); - SdrLayerID nBackground = rLayerAdmin.GetLayerID( SdResId( STR_LAYER_BCKGRND ) ); - SdrLayerID nBgObj = rLayerAdmin.GetLayerID( SdResId( STR_LAYER_BCKGRNDOBJ ) ); + SdrLayerID nBackground = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID nBgObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers(); // (#67720#) diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx index 2096f4be704e..0a42ecdad7b3 100644 --- a/sd/source/ui/unoidl/unolayer.cxx +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -75,62 +75,6 @@ static const SvxItemPropertySet* ImplGetSdLayerPropertySet() return &aSDLayerPropertySet_Impl; } -OUString SdLayer::convertToInternalName( const OUString& rName ) -{ - if ( rName == sUNO_LayerName_background ) - { - return SdResId( STR_LAYER_BCKGRND ); - } - else if ( rName == sUNO_LayerName_background_objects ) - { - return SdResId( STR_LAYER_BCKGRNDOBJ ); - } - else if ( rName == sUNO_LayerName_layout ) - { - return SdResId( STR_LAYER_LAYOUT ); - } - else if ( rName == sUNO_LayerName_controls ) - { - return SdResId( STR_LAYER_CONTROLS ); - } - else if ( rName == sUNO_LayerName_measurelines ) - { - return SdResId( STR_LAYER_MEASURELINES ); - } - else - { - return rName; - } -} - -OUString SdLayer::convertToExternalName( const OUString& rName ) -{ - if( rName == SdResId( STR_LAYER_BCKGRND ) ) - { - return OUString( sUNO_LayerName_background ); - } - else if( rName == SdResId( STR_LAYER_BCKGRNDOBJ ) ) - { - return OUString( sUNO_LayerName_background_objects ); - } - else if( rName == SdResId( STR_LAYER_LAYOUT ) ) - { - return OUString( sUNO_LayerName_layout ); - } - else if( rName == SdResId( STR_LAYER_CONTROLS ) ) - { - return OUString( sUNO_LayerName_controls ); - } - else if( rName == SdResId( STR_LAYER_MEASURELINES ) ) - { - return OUString( sUNO_LayerName_measurelines ); - } - else - { - return rName; - } -} - SdLayer::SdLayer(SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_) : mxLayerManager(pLayerManager_) , pLayer(pSdrLayer_) @@ -208,7 +152,7 @@ void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const un if(!(aValue >>= aName)) throw lang::IllegalArgumentException(); - pLayer->SetName(SdLayer::convertToInternalName( aName ) ); + pLayer->SetName(aName); mxLayerManager->UpdateLayerView(); break; } @@ -265,7 +209,7 @@ uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName ) break; case WID_LAYER_NAME: { - OUString aRet( SdLayer::convertToExternalName( pLayer->GetName() ) ); + OUString aRet(pLayer->GetName()); aValue <<= aRet; break; } @@ -614,7 +558,7 @@ uno::Any SAL_CALL SdLayerManager::getByName( const OUString& aName ) throw lang::DisposedException(); SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); - SdrLayer* pLayer = rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ) ); + SdrLayer* pLayer = rLayerAdmin.GetLayer(aName); if( pLayer == nullptr ) throw container::NoSuchElementException(); @@ -639,7 +583,7 @@ uno::Sequence< OUString > SAL_CALL SdLayerManager::getElementNames() { SdrLayer* pLayer = rLayerAdmin.GetLayer( nLayer ); if( pLayer ) - *pStrings++ = SdLayer::convertToExternalName( pLayer->GetName() ); + *pStrings++ = pLayer->GetName(); } return aSeq; @@ -654,7 +598,7 @@ sal_Bool SAL_CALL SdLayerManager::hasByName( const OUString& aName ) SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); - return nullptr != rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ) ); + return nullptr != rLayerAdmin.GetLayer(aName); } // XElementAccess diff --git a/sd/source/ui/unoidl/unolayer.hxx b/sd/source/ui/unoidl/unolayer.hxx index 4388105c6c4e..a8ea2448f519 100644 --- a/sd/source/ui/unoidl/unolayer.hxx +++ b/sd/source/ui/unoidl/unolayer.hxx @@ -55,9 +55,6 @@ public: // intern SdrLayer* GetSdrLayer() const throw() { return pLayer; } - static OUString convertToInternalName( const OUString& rName ); - static OUString convertToExternalName( const OUString& rName ); - // uno helper UNO3_GETIMPLEMENTATION_DECL( SdLayer ) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 2ba00268001c..bc9553287cec 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -471,8 +471,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate ) { sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PageKind::Standard ); SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdPage* pStandardPage = nullptr; @@ -531,8 +531,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate ) pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, true ); } - aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); aVisibleLayers.Set(aBckgrnd, bIsPageBack); aVisibleLayers.Set(aBckgrndObj, bIsPageObj); pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index b24a6e5fd4df..18439a352df0 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -387,16 +387,6 @@ uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) else { uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) ); - - if ( aPropertyName == sUNO_shape_layername ) - { - OUString aName; - if( aRet >>= aName ) - { - aName = SdLayer::convertToExternalName( aName ); - aRet <<= aName; - } - } return aRet; } } @@ -660,17 +650,6 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c else { uno::Any aAny( aValue ); - - if ( aPropertyName == sUNO_shape_layername ) - { - OUString aName; - if( aAny >>= aName ) - { - aName = SdLayer::convertToInternalName( aName ); - aAny <<= aName; - } - } - mpShape->_setPropertyValue(aPropertyName, aAny); } @@ -815,16 +794,6 @@ css::uno::Any SAL_CALL SdXShape::getPropertyValue( const OUString& PropertyName else { aRet = mpShape->_getPropertyValue(PropertyName); - - if ( PropertyName == sUNO_shape_layername ) - { - OUString aName; - if( aRet >>= aName ) - { - aName = SdLayer::convertToExternalName( aName ); - aRet <<= aName; - } - } } return aRet; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 95aec6b9b17e..fd703a97b9ce 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -764,7 +764,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName { SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin(); SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); - aVisibleLayers.Set(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)), bVisible); + aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background), bVisible); pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); } } @@ -784,7 +784,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName { SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin(); SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); - aVisibleLayers.Set(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)), bVisible); + aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects), bVisible); pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); } } @@ -1183,7 +1183,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) { SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin(); SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); - aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND))); + aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background)); } else { @@ -1202,7 +1202,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) { SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin(); SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); - aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ))); + aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects)); } else { diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx index b93db139d119..df2fbaeaeda8 100644 --- a/sd/source/ui/view/ViewShellImplementation.cxx +++ b/sd/source/ui/view/ViewShellImplementation.cxx @@ -24,6 +24,7 @@ #include <sdpage.hxx> #include <drawdoc.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <strings.hrc> #include <app.hrc> #include <sdattr.hxx> @@ -194,8 +195,8 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( pCurrentPage->SetAutoLayout(aNewAutoLayout, true); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); aVisibleLayers.Set(aBckgrnd, bBVisible); aVisibleLayers.Set(aBckgrndObj, bBObjsVisible); pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); @@ -255,8 +256,8 @@ void ViewShell::Implementation::AssignLayout ( SfxRequest const & rRequest, Page // Transform the given request into the four argument form that is // understood by ProcessModifyPageSlot(). SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin()); - SdrLayerID aBackground (rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND))); - SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ))); + SdrLayerID aBackground (rLayerAdmin.GetLayerID(sUNO_LayerName_background)); + SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects)); SdrLayerIDSet aVisibleLayers; diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 98a39465d8e5..d6272c24ff29 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -53,6 +53,7 @@ #include <sdmod.hxx> #include <fupoor.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <fusel.hxx> #include <sdpage.hxx> #include <FrameView.hxx> @@ -1141,24 +1142,19 @@ void DrawViewShell::ResetActualLayer() LayerTabBar* pLayerBar = GetLayerTabControl(); if (pLayerBar != nullptr) { - // remember old layer count and current layer id + // remember old tab count and current tab id // this is needed when one layer is renamed to - // restore current layer - sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount(); - sal_uInt16 nOldLayerPos = pLayerBar->GetCurPageId(); + // restore current tab + sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount(); // actually it is tab count + sal_uInt16 nOldLayerPos = pLayerBar->GetCurPageId(); // actually it is a tab nId /** * Update for LayerTab */ pLayerBar->Clear(); - OUString aName; + OUString aName; // a real layer name OUString aActiveLayer = mpDrawView->GetActiveLayer(); - OUString aBackgroundLayer = SdResId(STR_LAYER_BCKGRND); - OUString aBackgroundObjLayer = SdResId(STR_LAYER_BCKGRNDOBJ); - OUString aLayoutLayer = SdResId(STR_LAYER_LAYOUT); - OUString aControlsLayer = SdResId(STR_LAYER_CONTROLS); - OUString aMeasureLinesLayer = SdResId(STR_LAYER_MEASURELINES); sal_uInt16 nActiveLayerPos = SDRLAYERPOS_NOTFOUND; SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); @@ -1172,22 +1168,17 @@ void DrawViewShell::ResetActualLayer() nActiveLayerPos = nLayerPos; } - if ( aName != aBackgroundLayer ) + if ( aName != sUNO_LayerName_background ) // layer "background" has never a tab { if (meEditMode == EditMode::MasterPage) { // don't show page layer onto the masterpage - if (aName != aLayoutLayer && - aName != aControlsLayer && - aName != aMeasureLinesLayer) + if (aName != sUNO_LayerName_layout && + aName != sUNO_LayerName_controls && + aName != sUNO_LayerName_measurelines) { - pLayerBar->InsertPage(nLayerPos+1, aName); - - // Set page bits for modified tab name display - TabBarPageBits nBits = TabBarPageBits::NONE; SdrPageView* pPV = mpDrawView->GetSdrPageView(); - if (pPV) { if (!pPV->IsLayerVisible(aName)) @@ -1204,22 +1195,15 @@ void DrawViewShell::ResetActualLayer() } } - // Save the bits - - pLayerBar->SetPageBits(nLayerPos+1, nBits); + pLayerBar->InsertPage(nLayerPos+1, aName, nBits); // why +1? It is a nId, not a position. Position is APPEND. } } else { // don't show masterpage layer onto the page - if (aName != aBackgroundObjLayer) + if (aName != sUNO_LayerName_background_objects) { - pLayerBar->InsertPage(nLayerPos+1, aName); - - // Set page bits for modified tab name display - TabBarPageBits nBits = TabBarPageBits::NONE; - if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName)) { nBits = TabBarPageBits::Blue; @@ -1233,9 +1217,7 @@ void DrawViewShell::ResetActualLayer() nBits |= TabBarPageBits::Underline; } - // Save the bits - - pLayerBar->SetPageBits(nLayerPos+1, nBits); + pLayerBar->InsertPage(nLayerPos+1, aName, nBits);// why +1? } } } @@ -1252,7 +1234,7 @@ void DrawViewShell::ResetActualLayer() nActiveLayerPos = ( meEditMode == EditMode::MasterPage ) ? 2 : 0; } - mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayerPos + 1) ); + mpDrawView->SetActiveLayer( pLayerBar->GetLayerName(nActiveLayerPos + 1) );// why +1? } pLayerBar->SetCurPageId(nActiveLayerPos + 1); diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 7a8433da90f0..7ccdb99ea046 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -175,6 +175,7 @@ #include <sdgrffilter.hxx> #include <sdpage.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <slideshow.hxx> #include <stlpool.hxx> #include <undolayer.hxx> @@ -1810,7 +1811,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); if( rLayerAdmin.GetLayer( aLayerName ) - || aLayerName.isEmpty() ) + || aLayerName.isEmpty() + || LayerTabBar::IsLocalizedNameOfStandardLayer( aLayerName) ) { // name already exists std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), @@ -1918,7 +1920,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId(); - OUString aLayerName = GetLayerTabControl()->GetPageText(nCurPage); + OUString aLayerName = GetLayerTabControl()->GetLayerName(nCurPage); SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName); OUString aLayerTitle = pLayer->GetTitle(); @@ -1935,20 +1937,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) const SfxItemSet* pArgs = rReq.GetArgs(); // is it allowed to delete the layer? - bool bDelete = true; - - OUString aLayoutLayer = SdResId(STR_LAYER_LAYOUT); - OUString aControlsLayer = SdResId(STR_LAYER_CONTROLS); - OUString aMeasureLinesLayer = SdResId(STR_LAYER_MEASURELINES); - OUString aBackgroundLayer = SdResId(STR_LAYER_BCKGRND); - OUString aBackgroundObjLayer = SdResId(STR_LAYER_BCKGRNDOBJ); - - if( aLayerName == aLayoutLayer || aLayerName == aControlsLayer || - aLayerName == aMeasureLinesLayer || - aLayerName == aBackgroundLayer || aLayerName == aBackgroundObjLayer ) - { - bDelete = false; - } + bool bDelete = !( LayerTabBar::IsRealNameOfStandardLayer(aLayerName) ); if (! pArgs) { @@ -1974,18 +1963,24 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { pDlg->GetAttr( aNewAttr ); aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); - - if( (rLayerAdmin.GetLayer( aLayerName ) && - aLayerName != aOldLayerName) || aLayerName.isEmpty() ) + if (bDelete) { - // name already exists - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), + if( (rLayerAdmin.GetLayer( aLayerName ) && aLayerName != aOldLayerName) + || LayerTabBar::IsRealNameOfStandardLayer(aLayerName) + || LayerTabBar::IsLocalizedNameOfStandardLayer(aLayerName) + || aLayerName.isEmpty() ) + { + // name already exists + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_WARN_NAME_DUPLICATE))); - xWarn->run(); + xWarn->run(); + } + else + bLoop = false; } else - bLoop = false; + bLoop = false; // altering name is already disabled in the dialog itself } switch (nRet) { @@ -3279,6 +3274,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { // Determine current page and toggle visibility of layers // associated with master page background or master page shapes. + // FIXME: This solution is wrong, because shapes of master pages need + // not be on layer "background" or "backgroundobjects". + // See tdf#118613 SdPage* pPage = GetActualPage(); if (pPage != nullptr && GetDoc() != nullptr) @@ -3287,9 +3285,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); SdrLayerID aLayerId; if (nSId == SID_DISPLAY_MASTER_BACKGROUND) - aLayerId = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); + aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background); else - aLayerId = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); aVisibleLayers.Set(aLayerId, !aVisibleLayers.IsSet(aLayerId)); pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); } diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index aa433c0d84c7..de0d97335ec0 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -65,6 +65,7 @@ #include <sdpage.hxx> #include <Window.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <drawview.hxx> #include <drawdoc.hxx> #include <Ruler.hxx> @@ -224,7 +225,11 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) if(bCurPageValid) { - mpDrawView->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage) ); + OUString aLayerName( GetLayerTabControl()->GetLayerName(nCurPage)); + if (!aLayerName.isEmpty()) + { + mpDrawView->SetActiveLayer(aLayerName); + } Invalidate(); } @@ -252,7 +257,7 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) } // turn on default layer of page - mpDrawView->SetActiveLayer(SdResId(STR_LAYER_LAYOUT)); + mpDrawView->SetActiveLayer(sUNO_LayerName_layout); ChangeEditMode(EditMode::Page, mbIsLayerModeActive); diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 32f9fcf96c0f..97d832c1f5ad 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -99,11 +99,18 @@ void DrawViewShell::DeleteActualLayer() } SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin(); - const OUString& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId()); + sal_uInt16 nId = GetLayerTabControl()->GetCurPageId(); + const OUString& rName = GetLayerTabControl()->GetLayerName(nId); + if(LayerTabBar::IsRealNameOfStandardLayer(rName)) + { + assert(false && "Standard layer may not be deleted."); + return; + } + const OUString& rDisplayName(GetLayerTabControl()->GetPageText(nId)); OUString aString(SdResId(STR_ASK_DELETE_LAYER)); // replace placeholder - aString = aString.replaceFirst("$", rName); + aString = aString.replaceFirst("$", rDisplayName); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx index bd9e9f849bb1..2266c7981d06 100644 --- a/sd/source/ui/view/drviews5.cxx +++ b/sd/source/ui/view/drviews5.cxx @@ -600,7 +600,7 @@ void DrawViewShell::SetActiveTabLayerIndex (int nIndex) if (nIndex>=0 && nIndex<pBar->GetPageCount()) { // Tell the draw view and the tab control of the new active layer. - mpDrawView->SetActiveLayer (pBar->GetPageText (pBar->GetPageId (static_cast<sal_uInt16>(nIndex)))); + mpDrawView->SetActiveLayer (pBar->GetLayerName (pBar->GetPageId (static_cast<sal_uInt16>(nIndex)))); pBar->SetCurPageId (pBar->GetPageId (static_cast<sal_uInt16>(nIndex))); rtl::Reference<SdUnoDrawView> pUnoDrawView(new SdUnoDrawView ( *this, diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 22bc8d5955a8..129f7904a949 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -81,7 +81,7 @@ #include <drawdoc.hxx> #include <DrawViewShell.hxx> #include <sdmod.hxx> -#include <sdresid.hxx> +#include <unokywds.hxx> #include <sdpage.hxx> #include <Client.hxx> #include <DrawDocShell.hxx> @@ -863,16 +863,9 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) if(GetLayerTabControl()) // #i87182# { sal_uInt16 nCurrentLayer = GetLayerTabControl()->GetCurPageId(); - const OUString& rName = GetLayerTabControl()->GetPageText(nCurrentLayer); + const OUString& rName = GetLayerTabControl()->GetLayerName(nCurrentLayer); - bool bDisableIt = !IsLayerModeActive(); - bDisableIt |= (rName == SdResId(STR_LAYER_LAYOUT)); - bDisableIt |= (rName == SdResId(STR_LAYER_BCKGRND)); - bDisableIt |= (rName == SdResId(STR_LAYER_BCKGRNDOBJ)); - bDisableIt |= (rName == SdResId(STR_LAYER_CONTROLS)); - bDisableIt |= (rName == SdResId(STR_LAYER_MEASURELINES)); - - if (bDisableIt) + if (!IsLayerModeActive() || LayerTabBar::IsRealNameOfStandardLayer(rName)) { rSet.DisableItem(SID_DELETE_LAYER); rSet.DisableItem(SID_RENAMELAYER); @@ -1570,8 +1563,8 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); - SdrLayerID aBackgroundId = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aObjectId = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBackgroundId = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aObjectId = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_BACKGROUND, aVisibleLayers.IsSet(aBackgroundId))); rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_OBJECTS, diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 31ada8f087e0..6fc9e12def03 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -70,6 +70,7 @@ #include <annotationmanager.hxx> #include <DrawController.hxx> #include <tools/diagnose_ex.h> +#include <LayerTabBar.hxx> #include <memory> @@ -701,7 +702,7 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) if( pLayer ) { aOUString += " (" ; - aOUString += pLayer->GetName(); + aOUString += LayerTabBar::convertToLocalizedName(pLayer->GetName()); aOUString += ")"; } } diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx index 9fd8f21f5cd7..540cc6e006fb 100644 --- a/sd/source/ui/view/drviewsb.cxx +++ b/sd/source/ui/view/drviewsb.cxx @@ -46,7 +46,7 @@ #include <sdattr.hxx> #include <drawdoc.hxx> #include <DrawDocShell.hxx> -#include <sdresid.hxx> +#include <unokywds.hxx> #include <sdpage.hxx> #include <DrawViewShell.hxx> #include <drawview.hxx> @@ -78,8 +78,8 @@ bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const OUString & rName ) // Undo SdPage* pUndoPage = pPageToRename; SdrLayerAdmin & rLayerAdmin = GetDoc()->GetLayerAdmin(); - SdrLayerID nBackground = rLayerAdmin.GetLayerID( SdResId(STR_LAYER_BCKGRND) ); - SdrLayerID nBgObj = rLayerAdmin.GetLayerID( SdResId(STR_LAYER_BCKGRNDOBJ) ); + SdrLayerID nBackground = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID nBgObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers(); SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); @@ -168,7 +168,7 @@ void DrawViewShell::ModifyLayer ( for( nPos = 0; nPos < nPageCount; nPos++ ) { sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos ); - if (GetLayerTabControl()->GetPageText(nId) == pLayer->GetName()) + if (GetLayerTabControl()->GetLayerName(nId) == pLayer->GetName()) { nCurPage = nId; break; diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index fbd489a74c98..61e8572cbaa5 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -80,6 +80,7 @@ #include <fuconarc.hxx> #include <fucon3d.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <Outliner.hxx> #include <PresentationViewShell.hxx> #include <sdpage.hxx> @@ -1019,7 +1020,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START)); // turn on default layer of MasterPage - mpDrawView->SetActiveLayer( SdResId(STR_LAYER_BCKGRNDOBJ) ); + mpDrawView->SetActiveLayer(sUNO_LayerName_background_objects); ChangeEditMode(EditMode::MasterPage, mbIsLayerModeActive); diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx index aa4f7af1a51e..d6a8cabb1aec 100644 --- a/sd/source/ui/view/frmview.cxx +++ b/sd/source/ui/view/frmview.cxx @@ -35,7 +35,7 @@ #include <DrawViewShell.hxx> #include <OutlineViewShell.hxx> #include <sdmod.hxx> -#include <sdresid.hxx> +#include <unokywds.hxx> #include <pres.hxx> #include <strings.hrc> #include <sdiocmpt.hxx> @@ -207,7 +207,7 @@ FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULL * rLayerAdmin.getLockedLayersODF(maLockedLayers); SetGridCoarse( Size( 1000, 1000 ) ); SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1)); - SetActiveLayer( SdResId(STR_LAYER_LAYOUT) ); + SetActiveLayer(sUNO_LayerName_layout); mbNoColors = true; mbNoAttribs = false; maVisArea = ::tools::Rectangle( Point(), Size(0, 0) ); diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 30ea493b2732..c0659cc7bf07 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -64,6 +64,7 @@ #include <sdmod.hxx> #include <sdpage.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <DrawViewShell.hxx> #include <futext.hxx> #include <fuinsfil.hxx> @@ -136,7 +137,7 @@ View::View( SetMinMoveDistancePixel(2); SetHitTolerancePixel(2); - SetMeasureLayer(SdResId(STR_LAYER_MEASURELINES)); + SetMeasureLayer(sUNO_LayerName_measurelines); // Timer for delayed drop (has to be for MAC) maDropErrorIdle.SetInvokeHandler( LINK(this, View, DropErrorHdl) ); diff --git a/sd/source/ui/view/unmodpg.cxx b/sd/source/ui/view/unmodpg.cxx index f5d3268ac361..b82e3413f717 100644 --- a/sd/source/ui/view/unmodpg.cxx +++ b/sd/source/ui/view/unmodpg.cxx @@ -31,6 +31,7 @@ #include <unmodpg.hxx> #include <sdpage.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <drawdoc.hxx> @@ -57,8 +58,8 @@ ModifyPageUndoAction::ModifyPageUndoAction( { maOldName = mpPage->GetName(); SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers(); mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd); @@ -103,8 +104,8 @@ void ModifyPageUndoAction::Undo() } SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers; aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible); aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible); @@ -146,8 +147,8 @@ void ModifyPageUndoAction::Redo() } SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers; aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible); aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible); diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx index 9da2781e63b4..53b3d3ce4052 100644 --- a/sd/source/ui/view/viewshe3.cxx +++ b/sd/source/ui/view/viewshe3.cxx @@ -69,6 +69,7 @@ #include <framework/FrameworkHelper.hxx> #include <optsitem.hxx> #include <sdresid.hxx> +#include <unokywds.hxx> #include <undo/undomanager.hxx> #include <svx/svxids.hrc> @@ -194,8 +195,8 @@ SdPage* ViewShell::CreateOrDuplicatePage ( sal_uInt16 nSId = rRequest.GetSlot(); SdDrawDocument* pDocument = GetDoc(); SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin(); - SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)); - SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)); + SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); + SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); SdrLayerIDSet aVisibleLayers; // Determine the page from which to copy some values, such as layers, // size, master page, to the new page. This is usually the given page. diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index ccad39c6253a..0d617312658d 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -202,6 +202,7 @@ struct ImplTabBarItem TabBarPageBits mnBits; OUString maText; OUString maHelpText; + OUString maAuxiliaryText; // used in LayerTabBar for real layer name tools::Rectangle maRect; long mnWidth; OString maHelpId; @@ -2234,6 +2235,24 @@ OUString TabBar::GetPageText(sal_uInt16 nPageId) const return OUString(); } +OUString TabBar::GetAuxiliaryText(sal_uInt16 nPageId) const +{ + sal_uInt16 nPos = GetPagePos(nPageId); + if (nPos != PAGE_NOT_FOUND) + return mpImpl->mpItemList[nPos]->maAuxiliaryText; + return OUString(); +} + +void TabBar::SetAuxiliaryText(sal_uInt16 nPageId, const OUString& rText ) +{ + sal_uInt16 nPos = GetPagePos(nPageId); + if (nPos != PAGE_NOT_FOUND) + { + mpImpl->mpItemList[nPos]->maAuxiliaryText = rText; + // no redraw bar, no CallEventListener, internal use in LayerTabBar + } +} + OUString TabBar::GetHelpText(sal_uInt16 nPageId) const { sal_uInt16 nPos = GetPagePos(nPageId); diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx index b40f3fa0dc90..1d87fb830f42 100644 --- a/svx/source/svdraw/svdlayer.cxx +++ b/svx/source/svdraw/svdlayer.cxx @@ -114,7 +114,7 @@ SdrLayerAdmin::SdrLayerAdmin(SdrLayerAdmin* pNewParent): aLayer(), pParent(pNewParent), pModel(nullptr), - maControlLayerName("Controls") + maControlLayerName("controls") { } @@ -122,7 +122,7 @@ SdrLayerAdmin::SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin): aLayer(), pParent(nullptr), pModel(nullptr), - maControlLayerName("Controls") + maControlLayerName("controls") { *this = rSrcLayerAdmin; } |