[Libreoffice-commits] core.git: Branch 'feature/gsoc14-colors' - 2 commits - include/svx svx/source
Krisztian Pinter
pin.terminator at gmail.com
Wed Jul 30 13:03:05 PDT 2014
include/svx/PaletteManager.hxx | 15 ++++++++-
svx/source/tbxctrls/PaletteManager.cxx | 50 ++++++++++++++++++++++++---------
svx/source/tbxctrls/tbcontrl.cxx | 17 ++---------
3 files changed, 54 insertions(+), 28 deletions(-)
New commits:
commit d1cd50957750a534d6ec1ba8a21bca1e3b8fe931
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date: Wed Jul 30 19:45:37 2014 +0200
Change vector<Palette*> to ptr_vector<Palette>
Change-Id: I1f2832235e8d2ea3517efdce809970ed5f1c6769
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index 9d40d48..e4144f9 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -25,12 +25,14 @@
#include <svx/tbxcolorupdate.hxx>
#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <comphelper/processfactory.hxx>
+
+#include <boost/ptr_container/ptr_vector.hpp>
class PaletteManager
{
@@ -41,7 +43,7 @@ class PaletteManager
svx::ToolboxButtonColorUpdater* mpBtnUpdater;
Color mLastColor;
- std::vector<Palette*> maPalettes;
+ boost::ptr_vector<Palette> maPalettes;
public:
PaletteManager();
~PaletteManager();
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index da80f23..98ae0b2 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -41,20 +41,14 @@ PaletteManager::PaletteManager() :
PaletteManager::~PaletteManager()
{
- for( std::vector<Palette*>::iterator it = maPalettes.begin();
- it != maPalettes.end();
- ++it)
- {
- delete *it;
- }
}
void PaletteManager::LoadPalettes()
{
+ maPalettes.clear();
OUString aPalPath = SvtPathOptions().GetPalettePath();
osl::Directory aDir(aPalPath);
- maPalettes.clear();
osl::DirectoryItem aDirItem;
osl::FileStatus aFileStat( osl_FileStatus_Mask_FileName |
osl_FileStatus_Mask_FileURL |
@@ -116,7 +110,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
}
else
{
- maPalettes[mnCurrentPalette-1]->LoadColorSet( rColorSet );
+ maPalettes[mnCurrentPalette-1].LoadColorSet( rColorSet );
mnColorCount = rColorSet.GetItemCount();
}
}
@@ -127,11 +121,11 @@ std::vector<OUString> PaletteManager::GetPaletteList()
aPaletteNames.push_back( STR_DEFAULT_PAL );
- for( std::vector<Palette*>::iterator it = maPalettes.begin();
+ for( boost::ptr_vector<Palette>::iterator it = maPalettes.begin();
it != maPalettes.end();
++it)
{
- aPaletteNames.push_back( (*it)->GetName() );
+ aPaletteNames.push_back( (*it).GetName() );
}
aPaletteNames.push_back( STR_DOC_COLORS );
@@ -161,7 +155,7 @@ OUString PaletteManager::GetPaletteName()
else if( mnCurrentPalette == mnNumOfPalettes - 1 )
return OUString( STR_DOC_COLORS );
else
- return maPalettes[mnCurrentPalette - 1]->GetName();
+ return maPalettes[mnCurrentPalette - 1].GetName();
}
const Color& PaletteManager::GetLastColor()
commit 0e72d33fca02f4eb965dd49a26f1a6f610196175
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date: Wed Jul 30 17:15:49 2014 +0200
Make color picker apply color immediately
Change-Id: I38695a43ced63bd5207b631a072231d81aa7e0f9
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index 1bd0bd1..9d40d48 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -24,6 +24,14 @@
#include <rtl/ustring.hxx>
#include <svx/tbxcolorupdate.hxx>
+#include <tools/urlobj.hxx>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <comphelper/processfactory.hxx>
+
class PaletteManager
{
sal_uInt16 mnNumOfPalettes;
@@ -48,7 +56,8 @@ public:
const Color& GetLastColor();
void SetLastColor(const Color& rLastColor);
void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
- void PopupColorPicker();
+ void PopupColorPicker(const OUString aCommand);
+ static void DispatchColorCommand(const OUString aCommand, const Color aColor);
};
#endif // INCLUDED_SVX_PALETTEMANAGER_HXX
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 95485ce..da80f23 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -21,7 +21,7 @@
#include <osl/file.hxx>
#include <unotools/pathoptions.hxx>
#include <sfx2/objsh.hxx>
-#include "svx/drawitem.hxx"
+#include <svx/drawitem.hxx>
#include <svx/dialogs.hrc>
#include <svtools/colrdlg.hxx>
@@ -179,7 +179,7 @@ void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
mpBtnUpdater = pBtnUpdater;
}
-void PaletteManager::PopupColorPicker()
+void PaletteManager::PopupColorPicker(const OUString aCommand)
{
SvColorDialog aColorDlg( 0 );
aColorDlg.SetColor ( mLastColor );
@@ -188,6 +188,36 @@ void PaletteManager::PopupColorPicker()
{
mpBtnUpdater->Update( aColorDlg.GetColor() );
mLastColor = aColorDlg.GetColor();
+ DispatchColorCommand(aCommand, mLastColor);
+ }
+}
+
+void PaletteManager::DispatchColorCommand(const OUString aCommand, const Color aColor)
+{
+ using namespace css::uno;
+ using namespace css::frame;
+ using namespace css::beans;
+ using namespace css::util;
+
+ Reference<XComponentContext> xContext(comphelper::getProcessComponentContext());
+ Reference<XDesktop2> xDesktop = Desktop::create(xContext);
+ Reference<XDispatchProvider> xDispatchProvider(xDesktop->getCurrentFrame(), UNO_QUERY );
+ if (xDispatchProvider.is())
+ {
+ INetURLObject aObj( aCommand );
+
+ Sequence<PropertyValue> aArgs(1);
+ aArgs[0].Name = aObj.GetURLPath();
+ aArgs[0].Value = makeAny(sal_Int32(aColor.GetColor()));
+
+ URL aTargetURL;
+ aTargetURL.Complete = aCommand;
+ Reference<XURLTransformer> xURLTransformer(URLTransformer::create(comphelper::getProcessComponentContext()));
+ xURLTransformer->parseStrict(aTargetURL);
+
+ Reference<XDispatch> xDispatch = xDispatchProvider->queryDispatch(aTargetURL, OUString(), 0);
+ if (xDispatch.is())
+ xDispatch->dispatch(aTargetURL, aArgs);
}
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 0574948..4274ad1 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1118,7 +1118,6 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
else
aColor = mpColorSet->GetItemColor( nItemId );
- SvxColorItem aColorItem( aColor, theSlotId );
/* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
This instance may be deleted in the meantime (i.e. when a dialog is opened
while in Dispatch()), accessing members will crash in this case. */
@@ -1127,20 +1126,10 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
if ( IsInPopupMode() )
EndPopupMode();
- INetURLObject aObj( maCommand );
-
- Any a;
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[0].Name = aObj.GetURLPath();
- aColorItem.QueryValue( a );
- aArgs[0].Value = a;
- SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
- maCommand,
- aArgs );
-
if ( maSelectedLink.IsSet() )
maSelectedLink.Call(&aColor);
+ PaletteManager::DispatchColorCommand(maCommand, aColor);
return 0;
}
@@ -1154,7 +1143,9 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
{
- mrPaletteManager.PopupColorPicker();
+ if ( IsInPopupMode() )
+ EndPopupMode();
+ mrPaletteManager.PopupColorPicker(maCommand);
return 0;
}
More information about the Libreoffice-commits
mailing list